home *** CD-ROM | disk | FTP | other *** search
Wrap
package iCat; import com.netobjects.nfc.api.CStringArray; import com.netobjects.nfc.api.ComponentApp; import com.netobjects.nfc.api.DAssetManager; import com.netobjects.nfc.api.DDrawPicture; import com.netobjects.nfc.api.DFile; import com.netobjects.nfc.api.DImage; import com.netobjects.nfc.api.DLayout; import com.netobjects.nfc.api.DMessageBox; import com.netobjects.nfc.api.DRect; import com.netobjects.nfc.api.DSite; import com.netobjects.nfc.api.DSize; import com.netobjects.nfc.api.IDInspector; import java.net.URLEncoder; public class iCatBuyNow extends ComponentApp { String ItemID = ""; String strImageFile = ""; String strReturnURL = ""; String strReturnURLEncoded = ""; int Image; DDrawPicture cdp; String codebase = ""; DAssetManager assetMan; public void onCopy() { this.assetMan.CopyAsset(this.Image); } protected void finalize() { this.assetMan.RemoveAsset(this.Image); this.ItemID = null; this.strImageFile = null; this.strReturnURL = null; this.strReturnURLEncoded = null; this.cdp = null; this.codebase = null; this.assetMan = null; } public String onInstall(DAssetManager var1, String var2) { this.assetMan = var1; this.codebase = var2; this.strImageFile = this.codebase + "\\iCatBuyNow.gif"; return "iCat Buy Now"; } public void onUnInstall(DAssetManager var1) { } public void onInspect(CStringArray var1, CStringArray var2) { var1.Set("Item ID"); var2.Set("String"); var1.Set("Return URL"); var2.Set("String"); var1.Set("Image"); var2.Set("Image"); } public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) { if (var3 == 1) { if (var1.compareTo("Item ID") == 0) { return this.ItemID; } if (var1.compareTo("Return URL") == 0) { return this.strReturnURL; } if (var1.compareTo("Image") == 0) { return Integer.toString(this.Image); } } else { if (var1.compareTo("Item ID") == 0) { this.ItemID = var2; } else if (var1.compareTo("Return URL") == 0) { this.strReturnURL = var2; this.strReturnURLEncoded = URLEncoder.encode(var2); } else if (var1.compareTo("Image") == 0) { this.assetMan.RemoveAsset(this.Image); this.Image = Integer.parseInt(var2, 10); this.strImageFile = this.assetMan.GetAssetLocation(this.Image, 1, 1); DImage var6 = new DImage(); var6.setImageFile(this.strImageFile); DSize var7 = var6.getSize(); this.cdp.SetSize(var7.getWidth(), var7.getHeight()); this.cdp.setImageFile(this.assetMan.GetAssetLocation(this.Image, -1, 1)); } this.cdp.Invalidate(true); } if (var5 != null) { var5.OnPropertyChanged(-1); } return ""; } public void onDrop(DLayout var1, DRect var2, int var3) { if (var3 == 1) { this.cdp = new DDrawPicture(); this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getRight(), var2.getBottom()); this.cdp.SetStyle(1, 1); this.cdp.setStretch(2); this.cdp.setUsePictureText(false); DImage var4 = new DImage(); var4.setImageFile(this.strImageFile); DSize var5 = var4.getSize(); this.cdp.SetSize(var5.getWidth(), var5.getHeight()); this.cdp.setImageFile(this.strImageFile); var1.AddObject(this.cdp); } } public void onPublish(DAssetManager var1, int var2) { String var4 = this.readiCatFile(); if (this.ItemID.length() == 0) { DMessageBox var5 = new DMessageBox(); var5.Warning("The Item ID property of an iCatBuyNow component in your site is not filled in.\r\nPlease enter this value and republish your site.\r\n"); } String var3 = "<A HREF=\"" + var4 + "/index.icl?execute=plugins--cart_addtoorder.icl&itmid=" + this.ItemID; if (this.strReturnURL.length() != 0) { var3 = var3 + "&srcdoc=" + this.strReturnURLEncoded; } var3 = var3 + "\" target=\"_top\" >"; this.cdp.setAltTag("Add this item to your shopping cart."); this.cdp.setHTMLBefore(var3); this.cdp.setHTMLAfter("</A>"); } public String readiCatFile() { String var1 = ""; DFile var2 = new DFile(); DSite var3 = new DSite(); String var4 = var3.getName(); if (var2.Open(this.codebase + "iCatInfo\\" + var4 + ".txt", 0)) { var1 = var2.ReadString(1000); var2.Close(); } else { DMessageBox var5 = new DMessageBox(); var5.Warning("The iCatCart component requires that you also use\r\nthe iCatBuilt or iCatAffiliate component on your site.\r\n\r\nPlease add one of these components to your site and republish.\r\n"); } return var1; } private void debug(String var1) { DMessageBox var2 = new DMessageBox(); var2.Warning(var1 + "\r\n"); } }